package hihocoder;
import java.util.Scanner;

/**
 * 
 */

/**
 * @author zhongfang
 *
 */
public class 分数调查 {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int N=scanner.nextInt();
		int M=scanner.nextInt();
		int Q=scanner.nextInt();
		int[] unionSet=new int[N+1];//并差集,0代表自己是根，没有父节点
		int[] value=new int[N+1];//每个人的预测分值
		for (int i = 0; i < M; i++) {
			int a=scanner.nextInt();
			int b=scanner.nextInt();
			int y=scanner.nextInt();
			unionSet[b]=a;//a是b的父节点
			value[b]=value[a]-y;
		}
		for (int i = 0; i < Q; i++) {
			int a=scanner.nextInt();
			int b=scanner.nextInt();
			if(find(unionSet,b)!=find(unionSet,a)){
				System.out.println(-1);
			}else {
				System.out.println(value[a]-value[b]);
			}
		}
	}

	private static int find(int[] unionSet, int b) {
		if(unionSet[b]==0){
			return b;
		}else {
			unionSet[b]=find(unionSet, unionSet[b]);
			return unionSet[b];
		}
	}

}
